import Vue from 'vue'
import Vuex from 'vuex'
// import * as user from './modules/user'

Vue.use(Vuex)
// export default new Vuex.Store({
//   modules: {
//     user
//   },
// })
export default new Vuex.Store({
	modules: {
		user: {
			namespaced: true,
			state: {
				user: [],
				count: 1
			},
			getters: {
				get: state => {
					console.log(state)
					return 123
				}
			},
			mutations: {
				increment(state, n) {
					state.count += n
				}
			},
			actions: {
				incrementAsync({
					commit
				}, data) {
					console.log(commit, data)
					return new Promise((resolve) => {
						setTimeout(() => {
							commit('increment', data.amount)
							resolve()
						}, 1000)
					})
				}
			}
		}
	}
})
